package com.zisu.springcloud.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

/**
 * @Desc: ""
 * @Author: caixiang
 * @DATE: 2020/9/24 10:04
 */
@RestController
@Slf4j
public class OrderNacosController {
    //在ApplicationContextConfig.class 中已经把RestTemplate 注入到spring容器中去了，所以这里直接拿就行了。
    @Resource
    private RestTemplate restTemplate;

    //把微服务配置地址写在yml 里面
    @Value("${service-url.nacos-user-service}")
    private String serverURL;

    @GetMapping(value = "/consumer/payment/nacos/{id}")
    public String paymentInfo(@PathVariable("id") Long id)
    {
        return restTemplate.getForObject(serverURL+"/payment/nacos/"+id,String.class);
    }
}
